package com.bilibili.juc.lockSupport;

/**
 * @author zuife
 * @description
 * @since 2024-04-29 11:41:23
 */
public class LockSupportDemo {
    Object objectLock = new Object();

    public static void main(String[] args) {
        Object objectLock = new Object();
        new Thread(() -> {
            synchronized (objectLock) {
                System.out.println(Thread.currentThread().getName() + "\t ---------come in");
                try {
                    objectLock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "t1").start();
        //暂停几秒钟线程
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(() -> {
            synchronized (objectLock) {
                objectLock.notify();
                System.out.println(Thread.currentThread().getName() + "\t ---------通知");
            }

        }, "t2").start();
    }
}
